package com.lhkj.ct.meta.modules.psychology.service.impl;

import com.lhkj.ct.base.mybatis.extension.service.impl.BatchHandleServiceImpl;
import com.lhkj.ct.meta.modules.psychology.mapper.ScaleReportContentMapper;
import com.lhkj.ct.meta.modules.psychology.model.dto.ReportContentDto;
import com.lhkj.ct.meta.modules.psychology.model.entity.TblScaleReportContent;
import com.lhkj.ct.meta.modules.psychology.service.ScaleReportContentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2023-10-16
 */
@Service
public class ScaleReportContentServiceImpl extends BatchHandleServiceImpl<ScaleReportContentMapper, TblScaleReportContent> implements ScaleReportContentService {

    @Override
    @Transactional
    public boolean updateContent(List<ReportContentDto> reportContent) {
        List<TblScaleReportContent> collect = reportContent.stream().map(m -> TblScaleReportContent.builder()
                .id(m.getId())
                .explanation(m.getExplanation())
                .recommend(m.getRecommend())
                .build()
        ).collect(Collectors.toList());
        return updateBatchById(collect);
    }
}
